package jssia.database.mysql.columns;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class FloatColumn extends Column {

    private static final float LOWER = -3.402823466E+38f;
    private static final float UPPER = 3.402823466E+38f;

    public FloatColumn() {
    }

    public float get(ResultSet rs) throws SQLException {
        return rs.getFloat(fullyQualifiedName);
    }

    public void set(PreparedStatement ps, int index, float value) throws SQLException {
        if (value < LOWER || value > UPPER)
            throw new IllegalArgumentException("Invalid value of " + value + ", must be between " + LOWER + " and " + UPPER);
        ps.setFloat(index, value);
    }
}
